import Banner from "../../Banner";

const { ccclass, property } = cc._decorator;

@ccclass
export default class HealthAdvicePanel extends cc.Component {
    ageLimitAtalsPath: string = `Sprites/Common/AgeLimit`;

    start() {
        Banner.Instance.SetCityIsWhite();

        this.node.getChildByName(`TitleLb`).active = !Banner.IS_ANDROID;
        this.node.getChildByName(`ContentLb`).active = !Banner.IS_ANDROID;
        this.node.getChildByName(`CompanyLb`).active = !Banner.IS_ANDROID;
        this.node.getChildByName(`ContentLb`).active = !Banner.IS_ANDROID;
        this.node.getChildByName(`LicenseLb`).active = !Banner.IS_ANDROID;
        this.node.getChildByName(`AgeLimitSp`).active = !Banner.IS_ANDROID;
        this.node.getChildByName(`LoadingLb`).active = Banner.IS_ANDROID;
        
        this.node.getChildByName(`CompanyLb`).getComponent(cc.Label).string = `${Banner.Owner}`;
        this.node.getChildByName(`LicenseLb`).getComponent(cc.Label).string = `${Banner.License}`;
        //适龄提示角标
        let ageLimitSp: cc.Sprite = this.node.getChildByName(`AgeLimitSp`).getComponent(cc.Sprite);
        switch (Banner.AgeLimit) {
            case 8:
                cc.loader.loadRes(this.ageLimitAtalsPath, cc.SpriteAtlas, (err, res: cc.SpriteAtlas) => {
                    ageLimitSp.spriteFrame = res.getSpriteFrame(`8`);
                });
                break;
            case 12:
                cc.loader.loadRes(this.ageLimitAtalsPath, cc.SpriteAtlas, (err, res: cc.SpriteAtlas) => {
                    ageLimitSp.spriteFrame = res.getSpriteFrame(`12`);
                });
                break;
            case 16:
                cc.loader.loadRes(this.ageLimitAtalsPath, cc.SpriteAtlas, (err, res: cc.SpriteAtlas) => {
                    ageLimitSp.spriteFrame = res.getSpriteFrame(`16`);
                });
                break;
            default:
                cc.loader.loadRes(this.ageLimitAtalsPath, cc.SpriteAtlas, (err, res: cc.SpriteAtlas) => {
                    ageLimitSp.spriteFrame = res.getSpriteFrame(`16`);
                });
                break;
        }
    }
}